home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / utility / uwserver.zip / uwserver.tar / lib / uw_shell.c < prev    next >
C/C++ Source or Header  |  1991-01-25  |  851b  |  32 lines

  1. /*
  2.  *    uw library - uw_shell
  3.  *
  4.  * Copyright 1986 by John D. Bruner.  All rights reserved.  Permission to
  5.  * copy this program is given provided that the copy is not sold and that
  6.  * this copyright notice is included.
  7.  */
  8. #include "uwlib.h"
  9.  
  10. char *uwshellname = "/bin/sh";    /* can be patched by caller if desired */
  11.  
  12. uwid_t
  13. uw_shell(wtype, cmd)
  14. uwtype_t wtype;
  15. char *cmd;
  16. {
  17.     register uwid_t uwid;
  18.  
  19.     /*
  20.      * Create a new window (using uw_fork()) and execute the specified
  21.      * shell command in it.  Returns the window ID of the new window
  22.      * (or -1 if the window creation failed)  There is no way to
  23.      * determine if the executed command failed.
  24.      */
  25.     if ((uwid = uw_fork(wtype, (int *)0)) == 0) {
  26.         (void)execl(uwshellname, uwshellname, "-c", cmd, (char *)0);
  27.         _exit(1);    /* we'd better not reach this point */
  28.         /*NOTREACHED*/
  29.     } else
  30.         return(uwid);
  31. }
  32.